package com.ptswitch.material.components;

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.corelib.base.AbstractConditional;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.ptswitch.material.model.contract.Contract;

public class IfContract extends AbstractConditional {

    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private String contractStatus;

    @Parameter
    private Contract contract;

    @Inject
    private ComponentResources componentResources;

    @Override
    protected boolean test() {
        if (contractStatus != null) {
            if (!contractStatus.equals(contract.getStatus())) {
                return false;
            }
        }
        return true;
    }

}
